**************************************************************************************************
*** This do file creates the replication results for 
*** Human Rights Violations and the Gender Gap in Asylum Recognition Rates 	*/
*** Thomas Plümper (Vienna University of Economics and Business)																		*/
*** Eric Neumayer (LSE)																			*/
*** 																							*/
*** Published in: Journal of European Public Policy, 2020															*/
**************************************************************************************************
**************************************************************************************************
/* Note: 
You have to change "local DIR" to the directory you copy the original stata files contained 	*/
/* in the zip file and then run the do file. 													*/
**************************************************************************************************

version 12.0
drop _all
clear matrix


capture net install outreg2, from(http://fmwww.bc.edu/RePEc/bocode/o)			/* checks whether outreg2 is installed 		*/


***********************************************************************************
local DIR = "d:\Research\Asylum and Migration"  /*change relative path to the directory where the files are located */
cd "`DIR'"
***********************************************************************************

use  "Article for JEPP (asylum).dta", replace



*** Table 1

quietly xtregar absdiff    getting_married fem_gen_mut_prev_women married_by_15_filled PTS_S   f_share_married m_share_married  share_minor_total ratio_male_female_seekers    if all_decided>200 ,


*** Main regressions
* Empty model
jackknife: xtregar absdiff   if all_decided>200 & e(sample), 
outreg2 using table1, excel replace  e(r2_o  rho_ar) dec(3) 2aster 


* Human rights 
jackknife: xtregar absdiff   getting_married fem_gen_mut_prev_women married_by_15_filled PTS_S     if all_decided>200  & e(sample),
outreg2 using table1, excel append  e(r2_o  rho_ar) dec(3) 2aster 


* Human rights & demographic composition
jackknife: xtregar absdiff    getting_married fem_gen_mut_prev_women married_by_15_filled PTS_S   f_share_married m_share_married  share_minor_total ratio_male_female_seekers    if all_decided>200 ,
outreg2 using table1, excel append  e(r2_o  rho_ar) dec(3) 2aster 


*** Table 2

** Robustness tests 1
tsset

* Baseline
jackknife: xtregar absdiff    getting_married fem_gen_mut_prev_women married_by_15_filled PTS_S    f_share_married m_share_married  share_minor_total ratio_male_female_seekers    if all_decided>200 ,
outreg2 using table2, excel replace  e(r2_o  rho_ar) dec(3) 2aster 

* Include additional control variables
jackknife: xtregar absdiff  getting_married fem_gen_mut_prev_women married_by_15_filled PTS_S   f_share_married m_share_married  share_minor_total ratio_male_female_seekers c.total_protected_rate##c.total_protected_rate##c.total_protected_rate   safe_country_origin  muslim_share_RCS_f  female_1834_to_allfemale male_1834_to_allmale     if all_decided>200 ,
outreg2 using table2, excel append  e(r2_o  rho_ar) dec(3) 2aster 

* Random  effects with year fixed effects & LDV
jackknife: xtreg absdiff l.absdiff  getting_married fem_gen_mut_prev_women married_by_15_filled PTS_S    f_share_married m_share_married  share_minor_total ratio_male_female_seekers   i.year   if all_decided>200 , re robust
outreg2 using table2, excel append  e(r2_o  rho_ar) dec(3) 2aster 


*** Table 3

** Robustness tests 2
tsset

* Baseline
jackknife: xtregar absdiff    getting_married fem_gen_mut_prev_women married_by_15_filled PTS_S    f_share_married m_share_married  share_minor_total ratio_male_female_seekers    if all_decided>200 ,
outreg2 using table3, excel replace  e(r2_o  rho_ar) dec(3) 2aster 

* Drop below p25 flows
preserve
quietly xtregar absdiff    getting_married fem_gen_mut_prev_women married_by_15_filled PTS_S    f_share_married m_share_married  share_minor_total ratio_male_female_seekers    if all_decided>200 ,
quietly sum all_decided if e(sample), detail
keep if all_decided>200 & all_decided>=r(p25)
jackknife: xtregar absdiff    getting_married fem_gen_mut_prev_women married_by_15_filled PTS_S    f_share_married m_share_married  share_minor_total ratio_male_female_seekers   ,
outreg2 using table3, excel append  e(r2_o  rho_ar) dec(3) 2aster 
restore

* Drop above p75 flows
preserve
quietly xtregar absdiff    getting_married fem_gen_mut_prev_women married_by_15_filled PTS_S    f_share_married m_share_married  share_minor_total ratio_male_female_seekers    if all_decided>200 ,
quietly sum all_decided if e(sample), detail
keep if all_decided>200 & all_decided<=r(p75)
jackknife: xtregar absdiff    getting_married fem_gen_mut_prev_women married_by_15_filled PTS_S    f_share_married m_share_married  share_minor_total ratio_male_female_seekers   ,
outreg2 using table3, excel append  e(r2_o  rho_ar) dec(3) 2aster 
restore


*** Non-reported robustness tests
* Pre-2017 versus 2017 onwards
reg absdiff  getting_married fem_gen_mut_prev_women married_by_15_filled PTS_S    f_share_married m_share_married  share_minor_total ratio_male_female_seekers  i.year   if all_decided>200 & year<=2016,
estimates store pre2017
reg absdiff  getting_married fem_gen_mut_prev_women married_by_15_filled PTS_S    f_share_married m_share_married  share_minor_total ratio_male_female_seekers  year  if all_decided>200 & year>2016,  
estimates store post2017
suest pre2017 post2017, cluster(country)

test [pre2017_mean]getting_married - [post2017_mean]getting_married = 0
test [pre2017_mean]fem_gen_mut_prev_women -       [post2017_mean]fem_gen_mut_prev_women = 0
test [pre2017_mean]married_by_15_filled -       [post2017_mean]married_by_15_filled = 0
test [pre2017_mean]PTS_S - [post2017_mean]PTS_S = 0
test [pre2017_mean]f_share_married - [post2017_mean]f_share_married = 0
test [pre2017_mean]m_share_married - [post2017_mean]m_share_married = 0
test [pre2017_mean]share_minor_total - [post2017_mean]share_minor_total = 0
test [pre2017_mean]ratio_male_female_seekers -       [post2017_mean]ratio_male_female_seekers = 0
test [pre2017_mean]_cons - [post2017_mean]_cons = 0




**** Correlation among main explanatory variables
quietly xtregar absdiff    getting_married fem_gen_mut_prev_women married_by_15_filled PTS_S   f_share_married m_share_married  share_minor_total ratio_male_female_seekers    if all_decided>200 ,
corr  getting_married fem_gen_mut_prev_women married_by_15_filled PTS_S if e(sample)

**** Descriptive stats
quietly xtregar absdiff    getting_married fem_gen_mut_prev_women married_by_15_filled PTS_S   f_share_married m_share_married  share_minor_total ratio_male_female_seekers    if all_decided>200 ,
sum absdiff    getting_married fem_gen_mut_prev_women married_by_15_filled PTS_S   f_share_married m_share_married  share_minor_total ratio_male_female_seekers  if e(sample)

**** Countries in sample with average gender gap in recognition rates
preserve
quietly xtregar absdiff    f_share_married m_share_married  share_minor_total ratio_male_female_seekers  getting_married fem_gen_mut_prev_women married_by_15_filled PTS_S     if all_decided>200 ,
keep if e(sample)
collapse absdiff  male_protected_rate  female_protected_rate, by(country)
list country  male_protected_rate female_protected_rate absdiff
restore

